<?php

session_start();

require_once("cfg/def.php");
require_once("cfg/cfg.php");
require_once("models/user.class.php");
require_once("lib/err.package.php");


$eHandler = new exceptionErrorHandler();
$eHandler->error_formatter = new SimpleFormatter();

Logger::$log_file = AJAX_LOG_FILE;


header('Content-Type: text/plain; charset=utf-8');

Logger::Write("call.php GET", print_r($_GET, true));
Logger::Write("call.php POST", print_r($_POST, true));

try
{
    $act = strtoupper(get_item($_GET, "act", ACT_ID));
    Logger::Write("ajax.php act", $act);
    switch($act)
    {
        case 'login':
            do_login();
            break;
    }
}
catch(Exception $e)
{
    Logger::Write("call.php", $e);
    $result = $e;
}


function do_login()
{
    //$user
}


function get_item($items, $key, $def = null)
{
    if(is_null($items)) return $def;
    if(!is_array($items)) return $def;
    if(isset($items[$key]))
        return $items[$key];
    else
        return $def;
}
